package pATT.profilingAlgorithm.PersonalSearcher;


import java.util.Iterator;



public abstract class Stemmer{

    public abstract String stem(String str);

	  public Instance applyFilter(Instance i) {
			return applyFilter(i, Reasoner.USING_DICTIONARY);
		}

	  public Instance applyFilter(Instance i, int dic) {
	    TermVector v = i.getVector();
	    TermVector newv = new TermVector();
	    
	    for (Iterator it=v.termIterator(); it.hasNext(); ) {
	      String s = it.next().toString();
	      String stem = stem(s);
	      if (dic == 0) Reasoner.addStem(s,stem);
	      if (!newv.contains(stem)) {
	      	newv.put(stem,v.get(s));
	      }
	    }
			i.setVector(newv);
			return i;
	  }
}